<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
    <script type="text/javascript">
    //抽象类 只能声明不能使用 手动抛错模拟
        
        //抽象工厂类实现继承
        
        var VehicleFactory=function(subType,superType){
            if(typeof VehicleFactory[superType]==='function'){
                //缓存类
                function f(){}
                f.prototype=new VehicleFactory[superType]();
                subType.constructor=subType
                subType.prototype=new f();
                // subType.prototype=new VehicleFactory[superType]();
            }else{
                throw new Error('未创建该抽象类')
            }
        }
        VehicleFactory.car=function(){
            this.type='car';
            this.id=13;
        };
        VehicleFactory.car.prototype={
            getPrice:function(){
                throw new Error('未创建该抽象类');
            }
            
        }
        var BW=function(price,id){
            this.price=price;

        }
        
        VehicleFactory(BW,'car')
        BW.prototype.getPrice=function(){
            return this.price;
        }
        var bw=new BW('10000',2);
        console.log(BW.prototype)
        console.log(bw.id)
        console.log(bw.getPrice())
        console.log('fuck-')
        function A(type,content){
            var s=new this[type](content)
            return s
        }
        A.prototype={
            a:function(content){
                console.log(content)
            }
        }
        var aa=new A('a',1234)
        // var bb=new aa
        function B(){

        }
        B.prototype={
            b:function(){
                
            }
        }
        var bb=new B()
        var c='b'
        // console.log(bb[c])
    </script>
    </body>
</html>